import { constantRoutes } from '@/router';
import { PermissionState } from './types';
export const usePermissionStore = defineStore('permission', {
  state: (): PermissionState => ({
    routes: [],
    addRoutes: [],
    defaultRoutes: [],
    topbarRouters: [],
    sidebarRouters: [],
  }),
  actions: {
    // SET_ROUTES
    setRoutes(routes) {
      this.addRoutes = routes;
      this.routes = constantRoutes.concat(routes);
    },
    // SET_DEFAULT_ROUTES
    setDefaultRoutes(routes) {
      this.defaultRoutes = constantRoutes.concat(routes);
    },
    // SET_TOPBAR_ROUTES
    setTopbarRoutes(routes) {
      // 顶部导航菜单默认添加统计报表栏指向首页
      const index = [
        {
          path: 'index',
          meta: { title: '统计报表', icon: 'dashboard' },
        },
      ];
      this.topbarRouters = routes.concat(index);
    },
    // SET_SIDEBAR_ROUTERS
    setSidebarRoutes(routes) {
      this.sidebarRouters = routes;
    },
  },
});
